﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="List.aspx.cs" Inherits="eTruck.Views.Cars.List" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>车辆信息管理</title>
    <link href="<%=Page.ResolveClientUrl("~/Styles/Site.css")%>" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="<%=Page.ResolveClientUrl("~/Styles/ss.gridview.css")%>"/>
    <link rel="stylesheet" type="text/css" href="<%=Page.ResolveClientUrl("~/Styles/themes/default/easyui.css")%>"/>
	<link rel="stylesheet" type="text/css" href="<%=Page.ResolveClientUrl("~/Styles/themes/icon.css")%>"/>
	<script type="text/javascript" src="<%=Page.ResolveClientUrl("~/Scripts/jquery.min.js")%>"></script>
	<script type="text/javascript" src="<%=Page.ResolveClientUrl("~/Scripts/jquery.easyui.min.js")%>"></script>
    <script type="text/javascript" src="<%=Page.ResolveClientUrl("~/Scripts/CheckBox.js")%>"></script>
    <script type="text/javascript" src="<%=Page.ResolveClientUrl("~/Scripts/ss.changebackground.js")%>"></script>
    <script type="text/javascript" src="<%=Page.ResolveClientUrl("~/Scripts/jquery.autocomplete.js")%>"></script>
    <link rel="stylesheet" type="text/css" href="<%=Page.ResolveClientUrl("~/Styles/jquery.autocomplete.css")%>" />
    <script language="javascript" src="Form.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {          
            $('#dlg').dialog('close');
           
            function formatItem(row, i, max, term) {
                return " <strong>" + row[1] + "</strong>";
            }
        });         
    </script>
    <script type="text/javascript">

        //add:0;modify:1;detail:2=>type
        function showDivObj(control, type) {
            var obj_txtCarNo = $("input[id*='txtCarNo']");
            var obj_Drop_Corporation = $("select[id*='Drop_Corporation']");
            var obj_Capacity = $("input[id*='txtCapacity']");
            var obj_Drop_Unit = $("input[id*='txtUnit']");

            var obj_CarID = $("input[id*='txtCarID']");

            obj_txtCarNo.removeAttr("disabled");
            obj_Drop_Corporation.removeAttr("disabled");
            obj_Capacity.removeAttr("disabled");
            obj_Drop_Unit.removeAttr("disabled");
           

            $("#btnSubmit").show();

            if (type == 0) {
                obj_txtCarNo.val("");
                obj_Drop_Corporation.val("");
                obj_Capacity.val("");
                obj_Drop_Unit.val("吨");
                obj_CarID.val("");              
            }
            else {
                var trItem = $("#" + control.id).closest("tr");
                obj_CarID.val(trItem.find("input[type=hidden][id*='key']").val());
                obj_txtCarNo.val(trItem.children("td").eq(1).html());
                obj_Drop_Corporation.val(trItem.find("input[type=hidden][id*='CorporationID']").val());
               // obj_Drop_Corporation.val(trItem.children("td").eq(2).html());
               
                obj_Capacity.val(trItem.children("td").eq(3).html());
                obj_Drop_Unit.val(trItem.children("td").eq(4).html());
               
                if (type == 2) {                    
                    obj_Drop_Corporation.attr("disabled", "disabled");
                    obj_Capacity.attr("disabled", "disabled");
                    obj_Drop_Unit.attr("disabled", "disabled");

                    $("#btnSubmit").hide();
                }
                obj_txtCarNo.attr("disabled", "disabled");
            }

            $('#dlg').dialog('open');
            return false;
        }

    </script>

    <style type="text/css">
        .ss_form_name
        {
            text-align: right;
        }
    </style>

</head>
<body>
    <form id="form1" runat="server">
    <div>
        <!--Search -->
            <table style="width: 100%;" cellpadding="2" cellspacing="1" class="border">
                <tr>
                    <td style="width: 80px" align="right" class="tdbg">
                         <b>关键字：</b>
                    </td>
                    <td class="tdbg">                       
                    <asp:TextBox ID="txtKeyword" runat="server"></asp:TextBox>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:Button ID="btnSearch" runat="server" Text="查询"  OnClick="btnSearch_Click" >
                    </asp:Button>                    
                        
                    </td>
                    <td class="tdbg">
                    </td>
                </tr>
            </table>
            <!--Search end-->
            <br />
            <table border="0" cellpadding="0" cellspacing="1" style="width: 100%;">
                <tr>
                    <td style="width: 1px;">                        
                    </td>
                    <td align="left">
                        <asp:Button ID="btnDelete" runat="server" Text="删除" OnClick="btnDelete_Click"/>  
                        <input type="button" id="btnAdd" name="add" value="添加" onclick="showDivObj(this,0)" />                    
                    </td>
                </tr>
            </table>
            <asp:GridView ID="gridView" runat="server" AllowPaging="True" Width="100%" CellPadding="3"  OnPageIndexChanging ="gridView_PageIndexChanging"
                    BorderWidth="1px" DataKeyNames="CarID" OnRowDataBound="gridView_RowDataBound" OnRowCommand="gridView_RowCommand"
                    AutoGenerateColumns="false" PageSize="10"  RowStyle-HorizontalAlign="Center" OnRowCreated="gridView_OnRowCreated">
                    <Columns>
                    <asp:TemplateField ControlStyle-Width="30" HeaderText="选择"    >
                                <ItemTemplate>
                                    <asp:CheckBox ID="DeleteThis" onclick="javascript:CCA(this);" runat="server" />
                                    <asp:HiddenField ID="key" runat="server" Value='<%#Eval("CarID") %>' />                                    
                                </ItemTemplate>
                            </asp:TemplateField> 
		                    <asp:BoundField DataField="Car_NO" HeaderText="车牌号" SortExpression="Car_NO" ItemStyle-HorizontalAlign="Center"  />
		                   <%-- <asp:BoundField DataField="Corporation" HeaderText="所属公司" SortExpression="Corporation" ItemStyle-HorizontalAlign="Center"  />  --%>
                             <asp:TemplateField  HeaderText="所属公司"    >
                                <ItemTemplate>                                   
                                    <asp:Label ID="Corporation" runat="server" Text=<%#Eval("Corporation") %>></asp:Label>
                                    <asp:HiddenField ID="CorporationID" runat="server" Value='<%#Eval("CorporationID") %>' />                                    
                                </ItemTemplate>
                            </asp:TemplateField> 
		                    <asp:BoundField DataField="Capacity" HeaderText="载重" SortExpression="Capacity" ItemStyle-HorizontalAlign="Center"  /> 
		                    <asp:BoundField DataField="Unit" HeaderText="单位" SortExpression="Unit" ItemStyle-HorizontalAlign="Center"  />                            		                   
                            <asp:TemplateField HeaderText="详细">
                            <ItemTemplate>
                                <input type="button" id="<%#Eval("CarID")%>" name="detail" value="详细" onclick="showDivObj(this,2)" />
                            </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="编辑">
                                <ItemTemplate>
                                    <input type="button" id="<%#Eval("CarID")%>" name="modify" value="编辑" onclick="showDivObj(this,1)" />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:ButtonField ButtonType="Button" CommandName="DeleteRow" Text="删除" HeaderText="删除" />
                        </Columns>
                        <HeaderStyle CssClass="ss_gv_title"/>
                </asp:GridView>
               
             <div id="dlg" class="easyui-dialog" title="车辆信息" style="width: 400px;
                height: 300px; padding: 10px">
                <table>
                    <tr>
                        <td class="ss_form_name">
                            车牌号:
                        </td>
                        <td class="ss_form_value">
                            <asp:TextBox ID="txtCarNo" runat="server" Width="200px" MaxLength="20" onblur="CarNoCheck(this)"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="ss_form_name">
                            所属公司:
                        </td>
                        <td class="ss_form_value">
                            <asp:DropDownList ID="Drop_Corporation" runat="server" Width="200">
                            </asp:DropDownList>
                           
                        </td>
                    </tr>
                    <tr>
                        <td class="ss_form_name">
                            载重:
                        </td>
                        <td class="ss_form_value">
                            <asp:TextBox ID="txtCapacity" runat="server" Width="200px" MaxLength="50" class="easyui-numberbox" ></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="ss_form_name">
                            单位:
                        </td>
                        <td class="ss_form_value">
                            <asp:TextBox ID="txtUnit" runat="server" Width="200px" MaxLength="50" Text="吨" ></asp:TextBox>
                                                   </td>
                    </tr>
                    
                    <tr>
                        <td colspan="2">
                            <div style=" visibility:hidden;">
                                <asp:TextBox ID="txtCarID" runat="server" />                                
                            </div>
                        </td>
                    </tr>
                </table>
                <input type="button" id="btnSubmit" name="submit" value="确定" onclick="submit()"/>
                <asp:Button ID="Button2" runat="server" Text="取消" OnClientClick=" $('#dlg').dialog('close')" />
            </div>
    </div>
     <asp:HiddenField  ID="HiddenField1" runat="server" Value="" />
    <asp:HiddenField ID="HiddenField2" runat="server" />
    <asp:HiddenField ID="HiddenField3" runat="server" />
    </form>
    
 
<script type="text/javascript">

   

    function alertmessage(Title, Message, AlertType) {
        $.messager.alert(Title, Message, AlertType);
        document.getElementById("HiddenField1").value = "";
        document.getElementById("HiddenField2").value = "";
        document.getElementById("HiddenField3").value = "";

    }

    if (document.getElementById("HiddenField1").value != "") {
        alertmessage(document.getElementById("HiddenField1").value, document.getElementById("HiddenField2").value, document.getElementById("HiddenField3").value);
    }
</script>
</body>
</html>
